<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- Swiper7 -->
    <link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.css">
    <script src="https://unpkg.com/swiper/swiper-bundle.js"> </script>
    <script src="https://unpkg.com/swiper/swiper-bundle.min.js.map"> </script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
    <!-- Demo styles -->
    <style>
        html,
        body {
            position: relative;
            height: 100%;
        }

        body {
            background: #eee;
            font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
            font-size: 14px;
            color: #000;
            margin: 0;
            padding: 0;
        }

        .swiper-container {
            width: 100vw;
            height: 100vh;
            

        }

        .swiper-slide {
            text-align: center;
            font-size: 18px;
            background: #fff;

            /* Center slide text vertically */
            display: -webkit-box;
            display: -ms-flexbox;
            display: -webkit-flex;
            display: flex;
            -webkit-box-pack: center;
            -ms-flex-pack: center;
            -webkit-justify-content: center;
            justify-content: center;
            -webkit-box-align: center;
            -ms-flex-align: center;
            -webkit-align-items: center;
            align-items: center;
            transition: 300ms;
            transform: scale(0.8);
        }

        .swiper-slide-active,
        .swiper-slide-duplicate-active {
            transform: scale(1);
        }
        img{
            width:80%;
            height:80%;
        }
    </style>
</head>

<body>


    <!-- Swiper -->
    <div class="swiper-container">
        <div class="swiper-wrapper">
            <div class="swiper-slide"><img src="https://picsum.photos/200/300" alt=""></div>
            <div class="swiper-slide"><img src="https://picsum.photos/200" alt=""></div>
            <div class="swiper-slide"><img src="https://picsum.photos/id/237/200/300" alt=""></div>
            <div class="swiper-slide"><img src="https://picsum.photos/200/300?grayscale" alt=""></div>
            <div class="swiper-slide"><img src="https://picsum.photos/200/300/?blur=2" alt=""></div>
            <div class="swiper-slide"><img src="https://picsum.photos/id/870/200/300?grayscale&blur=2" alt=""></div>
            <div class="swiper-slide"><img src="https://picsum.photos/200/300.jpg" alt=""></div>
            <div class="swiper-slide"><img src="https://picsum.photos/200/300.webp" alt=""></div>
            <div class="swiper-slide"><img src="https://picsum.photos/200/300.jpg" alt=""></div>
            <div class="swiper-slide"><img src="https://picsum.photos/seed/picsum/200/300" alt=""></div>
        </div>
        <!-- Add Pagination -->
        <div class="swiper-pagination"></div>
    </div>


<!-- 修改箭头颜色示范 -->
<div class="swiper-button-next swiper-button-white"></div> 
<div class="swiper-button-prev swiper-button-black"></div> 

    <!-- Initialize Swiper -->
    <script>
        var swiper = new Swiper('.swiper-container', {
           // autoplay : true, //自动播放
           autoplay: {
            delay: 1000,//1秒切换一次
          },
            slidesPerView: 3,
            spaceBetween: 30,
            centeredSlides: true,
            loop: true,
            navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
            },
            pagination: {
                el: '.swiper-pagination',
                clickable: true,
            },
        });


        function yemianfun() {
            var xmlhttp;
            xmlhttp = new XMLHttpRequest();
            xmlhttp.open("GET", "https://picsum.photos/200/300.webp", true);
            xmlhttp.responseType = "blob";
            xmlhttp.onload = function () {
                console.log(this);
                if (this.status == 200) {
                    var blob = this.response;
                    var img = document.createElement("img"); 
                    img.onload = function (e) {
                        window.URL.revokeObjectURL(img.src);
                    };
                    img.src = window.URL.createObjectURL(blob);
                    document.getElementsByClassName("swiper-slide").appendChild(img);
                }
            }
            xmlhttp.send();  
        }

        yemianfun()
    </script>
</body>

</html>